package com.example.appbarlayoutdemo.adapter;

import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;


import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.appbarlayoutdemo.R;
import com.example.appbarlayoutdemo.bean.BrandDetailBean;

import java.util.List;

/**
 * 作者: njb
 * 时间: 2019/6/1 19:01
 * 描述: 品牌标题分类筛选
 */
public class SortAdapter extends BaseQuickAdapter<BrandDetailBean.DataBean.CategoryListBean, BaseViewHolder> {
    private TextView textView;
    public SortAdapter(@Nullable List<BrandDetailBean .DataBean.CategoryListBean> data) {
        super(R.layout.item_filter_content,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BrandDetailBean .DataBean.CategoryListBean item) {
        if(item == null){
            return;
        }
        textView = helper.getView(R.id.tv_mark);
        textView.setText(item.getCategoryName());

        if(item.isCheck()){
            textView.setTextColor(ContextCompat.getColor(mContext,R.color.white));
            textView.setBackground(ContextCompat.getDrawable(mContext,R.drawable.shape_sort_black));
        }else {
            textView.setTextColor(ContextCompat.getColor(mContext,R.color.cf3f3f3));
            textView.setBackground(ContextCompat.getDrawable(mContext,R.drawable.shape_cf5f5f5));
        }
    }
}
